/**
 * 
 */
package sqs.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author kjleng
 *
 */
public class Questionnaire implements Serializable{
	private int questionnaireId;
	private String questionnaireTitle;
	private String description;
	private User owner;
	private List<Question> questions;
	private String active;
	private List<SubmittedQuestionnaire> submittedQuestionnaires = new ArrayList<SubmittedQuestionnaire>();
	private List<Scale> scales = new ArrayList<Scale>();
	
	public static final String ACTIVE="A";
	public static final String INACTIVE="I";
	
	public boolean equals(Questionnaire q){
		if(q.getQuestionnaireId()==this.getQuestionnaireId()){
			return true;
		}
		return false;
	}
	
	public boolean isActive(){
		if(active.equals(Questionnaire.ACTIVE)){
			return true;
		}
		else{
			return false;
		}
	}
	
	public String getActive() {
		return active;
	}
	public void setActive(String active) {
		this.active = active;
	}
	public List<Question> getQuestions() {
		return questions;
	}
	public void setQuestions(List<Question> questions) {
		this.questions = questions;
	}
	public int getQuestionnaireId() {
		return questionnaireId;
	}
	public void setQuestionnaireId(int questionnaireId) {
		this.questionnaireId = questionnaireId;
	}
	public String getQuestionnaireTitle() {
		return questionnaireTitle;
	}
	public void setQuestionnaireTitle(String questionnaireTitle) {
		this.questionnaireTitle = questionnaireTitle;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
	public User getOwner() {
		return owner;
	}
	public void setOwner(User owner) {
		this.owner = owner;
	}

	public List<SubmittedQuestionnaire> getSubmittedQuestionnaires() {
		return submittedQuestionnaires;
	}

	public void setSubmittedQuestionnaires(
			List<SubmittedQuestionnaire> submittedQuestionnaires) {
		this.submittedQuestionnaires = submittedQuestionnaires;
	}
	
	public boolean enterQuestionnaireBefore(User user){
		System.out.println("!!!!!!!!!!! number of SubmittedQuestionnaires = " +submittedQuestionnaires.size());
		Iterator<SubmittedQuestionnaire> i = submittedQuestionnaires.iterator();
		while(i.hasNext()){
			SubmittedQuestionnaire sq = i.next();
			User respondent = sq.getRespondent();
			if(respondent.getUsername().equals(user.getUsername())){
				return true;
			}
		}
		return false;
	}
	public List<Scale> getScales() {
		return scales;
	}

	public void setScales(List<Scale> scales) {
		this.scales = scales;
	}
	
}
